package com.sinry.message.enums;

import cn.hutool.core.bean.BeanUtil;
import org.springframework.amqp.rabbit.core.RabbitTemplate;

/**
 * @author linxinlei
 * @project sinry-cloud
 * @description
 * @date 2022/8/7
 **/
public interface RabbitHandler {

    String getExchange();
    String getQueue();
    Class<?> getMessageClass();

    default void send(RabbitTemplate rabbitTemplate, Object data) {
        rabbitTemplate.convertAndSend(getExchange(), getQueue(), BeanUtil.toBean(data, getMessageClass()));
    }
}
